package com.example.demo.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.pojo.HistoryRecord;
import com.example.demo.pojo.User;
import com.example.demo.service.HistoryRecordService;

@CrossOrigin
@Controller
@RequestMapping("/history")
public class HistoryRecordController {

	@Autowired
	private HistoryRecordService historyService;
	
	@RequestMapping(value="findresourceidofuser")
	@ResponseBody
	public List<HistoryRecord> findUserHistoryRecord(@RequestBody HistoryRecord history) {
		String returnMSG="未找到用户历史记录";
		List<HistoryRecord> msgFromService=new ArrayList();
		System.out.println(history);
		HistoryRecord user=new HistoryRecord();
		user.setUserAccount(history.getUserAccount());
		msgFromService=historyService.findUserHistoryRecord(user);
		if(msgFromService!=null) {
			returnMSG="1";
		}else {
			returnMSG="未找到用户历史记录";
		}
		return msgFromService;
		
	}
}
